package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.BaseData;
import com.cskaoyan.bean.bo.IssueCreateBO;
import com.cskaoyan.bean.bo.IssueListBO;
import com.cskaoyan.bean.pojo.MallIssue;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.IssueCreateVO;
import com.cskaoyan.service.IssueService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: ycb
 * @description: 通用问题
 * @time: 2021/7/9 15:36
 */
@RestController
@RequestMapping("admin/issue")
public class IssueController {

    @Autowired
    IssueService issueService;

    /**
     * @Author ycb
     * @description: 获取通用问题列表
     * @Date 16:10 2021/7/9
     * url: http://182.92.235.201:8083/admin/issue/list?page=1&limit=20&question=11&sort=add_time&order=desc
     */
    @RequestMapping("list")
    @RequiresPermissions("admin:issue:list")
    public BaseRespVo list(IssueListBO issueListBO){
        BaseData<MallIssue> listVO = issueService.getIssueList(issueListBO);
        return BaseRespVo.ok(listVO);
    }

    /**
     * @Author ycb
     * @description: 添加问题
     * @Date 17:02 2021/7/9
     * url:http://182.92.235.201:8083/admin/issue/create
     */
    @RequestMapping("create")
    @RequiresPermissions("admin:issue:create")
    public BaseRespVo create(@RequestBody IssueCreateBO createBO){
        IssueCreateVO issueCreateVO = issueService.CreatIssue(createBO);
        return BaseRespVo.ok(issueCreateVO);
    }

    /**
     * @Author ycb
     * @description: 编辑问题
     * @Date 19:33 2021/7/9
     * url:   http://182.92.235.201:8083/admin/issue/update
     */
    @RequestMapping("update")
    @RequiresPermissions("admin:issue:update")
    public BaseRespVo update(@RequestBody MallIssue mallIssueBo){
        MallIssue mallIssueVo = issueService.issueUpdate(mallIssueBo);
        return BaseRespVo.ok(mallIssueVo);
    }

    /**
     * @Author ycb
     * @description: 删除问题
     * @Date 20:11 2021/7/9
     * url: http://182.92.235.201:8083/admin/issue/delete
     */
    @RequestMapping("delete")
    @RequiresPermissions("admin:issue:delete")
    public BaseRespVo delete(@RequestBody MallIssue mallIssueBo){
        issueService.deleteIssue(mallIssueBo);
        return BaseRespVo.ok();
    }
}